﻿<DemoPageSectionComponent Id="FileManagement-FileInput-MultiFileSelection">

    <div class="upload-container">
        <div style="@(SelectedFilesCount > 0 ? "display: none" : string.Empty)">
            <span class="drop-file-icon mb-3"></span>
            <span class="mb-3">Click the Select Files button to select a file</span>
        </div>
        <DxFileInput
                  AllowMultiFileUpload="true"
                  SelectedFilesChanged="@SelectedFilesChanged"
                  MaxFileSize="15000000"
                  FilesUploading="OnFilesUploading">
        </DxFileInput>
    </div>

    @code {
        int SelectedFilesCount { get; set; }

        protected void SelectedFilesChanged(IEnumerable<UploadFileInfo> files) {
            SelectedFilesCount = files.ToList().Count;
            InvokeAsync(StateHasChanged);
        }

        protected async Task OnFilesUploading(FilesUploadingEventArgs args) {
            foreach (var file in args.Files) {
                using var stream = new System.IO.MemoryStream();
                await file.OpenReadStream(file.Size).CopyToAsync(stream);            
            }
        }
    }
</DemoPageSectionComponent>
